define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    if(Config.accounturl == '' || Config.accounturl == null){
        Config.accounturl = 0;
    }
    if(Config.timedate == '' || Config.timedate == null){
        Config.timedate = 0;
    }
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'feditionreportone/index/?accounturl=' + Config.accounturl+'&timedate=' + Config.timedate,
                    add_url: 'feditionreportone/add',
                    edit_url: 'feditionreportone/edit',
                    del_url: 'feditionreportone/del',
                    multi_url: 'feditionreportone/multi',
                    import_url: 'feditionreportone/import',
                    table: 'fedition_report',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'timedate', title: __('Timedate'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, datetimeFormat:"YYYY-MM-DD"},
                        {field: 'admin_id', title: __('操作人'),visible: false,addClass: "selectpage", extend: "data-source='auth/admin/index' data-field='nickname'"},
                        {field: 'admin_name', title: __('操作人'), operate: false},

                        // {field: 'amount', title: __('Amount'), operate:'BETWEEN'},
                        {field: 'advertising', title: __('Advertising'), operate:'BETWEEN'},
                        // {field: 'sales', title: __('Sales'), operate:'BETWEEN'},
                        // {field: 'output_ratio', title: __('Output_ratio'), operate: 'LIKE'},
                        // {field: 'through_rate', title: __('Through_rate'), operate: 'LIKE'},
                        // {field: 'conversion_rate', title: __('Conversion_rate'), operate: 'LIKE'},
                        // {field: 'cpc', title: __('Cpc'), operate: 'LIKE'},
                        // {field: 'single_transfer', title: __('Single_transfer'), operate: 'LIKE'},
                        // {field: 'single_quantity', title: __('Single_quantity'), operate: 'LIKE'},
                        // {field: 'passenger_volume', title: __('Passenger_volume'), operate: 'LIKE'},
                        // {field: 'delivery_area', title: __('Delivery_area'), operate: 'LIKE'},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 当表格数据加载完成时
            table.on('load-success.bs.table', function (e, data) {
                //这里可以获取从服务端获取的JSON数据
                // console.log('zamount',data.Statistics.zamount);
                // $("#zamount").text(data.Statistics.zamount);
                $("#zadvertising").text(data.Statistics.zadvertising);
                // $("#zsales").text(data.Statistics.zsales);
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});